package com.hzhr.iot.device.controller;

import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.controller.base.BaseController;
import com.hzhr.iot.device.model.regulatorDevice_maintenanceCard_item.*;
import com.hzhr.iot.device.service.RegulatorDevice_MaintenanceCard_ItemService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.text.ParseException;
import java.util.Map;

@Api(tags = "RegulatorDevice_MaintenanceCard_Item", description = "调压设备的维护卡片的选项")
@RestController
@RequestMapping(value = "")
public class RegulatorDevice_MaintenanceCard_ItemController extends BaseController {
    @Autowired
    RegulatorDevice_MaintenanceCard_ItemService regulatorDevice_maintenanceCard_itemService;

    //region /regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items POST
    //region swagger响应码 : postByRegulatorDeviceIdAndMaintenanceCardId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : postByRegulatorDeviceIdAndMaintenanceCardId
    @ApiOperation(value="根据调压设备编号和维护卡编号创建该调压设备下维护卡的选项", notes="根据调压设备编号和维护卡编号创建该调压设备下维护卡的选项  \n简介 : 根据调压设备编号和维护卡编号创建该调压设备下维护卡的选项  \n步骤 :  \n1. 查询设备维护卡片 :  \n 根据路径参数regulatorDeviceId和maintenanceCardId查询设备卡片(DEVICE_MAINTENANCE_CARD)对象deviceMaintenance_1，  \n 路径参数筛选规则如下：  \n (1) deviceMaintenance_1.deviceId = 路径参数regulatorDeviceId；  \n (2) deviceMaintenance_1.id = 路径参数maintenanceCardId；  \n如果deviceMaintenance_1不存在，抛出异常201；  \n2. 创建维护卡片选项 :  \n 根据body创建维护卡片选项(DEVICE_MAINTENANCE_CARD_ITEM)对象deviceMaintenanceItem_1，  \n 额外属性设置规则如下：  \n deviceMaintenanceItem_1.cardId = deviceMaintenance_1.id;  \n3. 返回信息 :  \n 根据条件参数查询修改后的对象deviceMaintenanceItem_1的信息生成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : postByRegulatorDeviceIdAndMaintenanceCardId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "maintenanceCardId", value = "维护卡编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : postByRegulatorDeviceIdAndMaintenanceCardId
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items", method = RequestMethod.POST)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_MaintenanceCard_ItemGetModel> postByRegulatorDeviceIdAndMaintenanceCardId(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId,
                                                                                                                    @PathVariable("maintenanceCardId") Integer maintenanceCardId,
                                                                                                                    @RequestParam @ApiIgnore Map<String, Object> query,
                                                                                                                    @RequestBody RegulatorDevice_MaintenanceCard_ItemPostModel body) throws ServiceException, ParseException {
        RegulatorDevice_MaintenanceCard_ItemGetModel responseBody = regulatorDevice_maintenanceCard_itemService.postByRegulatorDeviceIdAndMaintenanceCardId(initHeader(), regulatorDeviceId, maintenanceCardId, query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items/{id} DELETE
    //region swagger响应码 : deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiOperation(value="根据调压设备编号和维护卡编号和维护卡选项编号删除调压设备下维护卡的选项", notes="根据调压设备编号和维护卡编号和维护卡选项编号删除调压设备下维护卡的选项  \n简介 : 根据调压设备编号和维护卡编号和维护卡选项编号删除调压设备下维护卡的选项  \n步骤 :  \n1. 删除维护卡片选项 :  \n 根据路径参数regulatorDeviceId、maintenanceCardId和id删除维护卡片选项(DEVICE_MAINTENANCE_CARD_ITEM)deviceMaintenanceItem_1，  \n 路径参数筛选规则如下：  \n (1) deviceMaintenanceItem_1.id = 路径参数id；  \n (2) deviceMaintenanceItem_1.cardId = 路径参数maintenanceCardId；  \n (3) deviceMaintenanceItem_1.cardExt.deviceId = 路径参数regulatorDeviceId；  \n2. 返回信息 :  \n 根据删除情况组装响应并返回结果  \n",produces = "application/json")
    //endregion
    //region swagger参数 : deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "maintenanceCardId", value = "维护卡编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "id", value = "维护卡的选项编号",required = true, dataType = "int", paramType = "path"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

    })
    //endregion
    //region 请求 : deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items/{id}", method = RequestMethod.DELETE)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_MaintenanceCard_ItemDeleteModel> deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId,
                                                                                                                              @PathVariable("maintenanceCardId") Integer maintenanceCardId,
                                                                                                                              @PathVariable("id") Integer id,
                                                                                                                              @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDevice_MaintenanceCard_ItemDeleteModel responseBody = regulatorDevice_maintenanceCard_itemService.deleteByRegulatorDeviceIdAndMaintenanceCardIdAndId(initHeader(), regulatorDeviceId, maintenanceCardId, id, query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items/{id} PUT
    //region swagger响应码 : putByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : putByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiOperation(value="根据调压设备编号和维护卡编号和维护卡选项编号修改调压设备下维护卡的选项", notes="根据调压设备编号和维护卡编号和维护卡选项编号修改调压设备下维护卡的选项  \n简介 : 根据调压设备编号和维护卡编号和维护卡选项编号修改调压设备下维护卡的选项  \n步骤 :  \n1. 查询维护卡片选项：  \n 根据路径参数id查询维护卡片选项(DEVICE_MAINTENANCE_CARD_ITEM)对象deviceMaintenanceItem_1，  \n 路径参数筛选规则如下：  \n (1) 对象deviceMaintenanceItem_1.id = 路径参数id；  \n (2) 对象deviceMaintenanceItem_1.cardId = 路径参数maintenanceCardId；  \n (3) 对象deviceMaintenanceItem_1.cardExt.deviceId = 路径参数regulatorDeviceId；  \n 如果deviceMaintenanceItem_1不存在，抛出异常201；  \n2. 修改维护卡片选项 :  \n 根据body修改deviceMaintenanceItem_1；  \n3. 返回信息 :  \n 根据条件参数查询修改后的对象deviceMaintenanceItem_1的信息生成结果对象并返回；  \n",produces = "application/json")
    //endregion
    //region swagger参数 : putByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "maintenanceCardId", value = "维护卡编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "id", value = "维护卡的选项编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),

    })
    //endregion
    //region 请求 : putByRegulatorDeviceIdAndMaintenanceCardIdAndId
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items/{id}", method = RequestMethod.PUT)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_MaintenanceCard_ItemGetModel> putByRegulatorDeviceIdAndMaintenanceCardIdAndId(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId,
                                                                                                                        @PathVariable("maintenanceCardId") Integer maintenanceCardId,
                                                                                                                        @PathVariable("id") Integer id,
                                                                                                                        @RequestParam @ApiIgnore Map<String, Object> query,
                                                                                                                        @RequestBody RegulatorDevice_MaintenanceCard_ItemPutModel body) throws ServiceException {
        RegulatorDevice_MaintenanceCard_ItemGetModel responseBody = regulatorDevice_maintenanceCard_itemService.putByRegulatorDeviceIdAndMaintenanceCardIdAndId(initHeader(), regulatorDeviceId, maintenanceCardId, id, query, body);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
    //region /regulator-boxes/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items GET
    //region swagger响应码 : getByRegulatorDeviceIdAndMaintenanceCardId
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : getByRegulatorDeviceIdAndMaintenanceCardId
    @ApiOperation(value="根据调压设备编号和维护卡编号查询该调压设备下维护卡的选项", notes="根据调压设备编号和维护卡编号查询该调压设备下维护卡的选项  \n简介 : 根据调压设备编号和维护卡编号查询该调压设备下维护卡的选项  \n步骤 :  \n1. 查询维护卡片选项 :  \n 根据条件参数以及路径参数regulatorDeviceId和maintenanceCardId查询设备卡片(DEVICE_MAINTENANCE_CARD_ITEM)对象集合deviceMaintenanceCardItemList_1，  \n 路径参数的筛选规则如下：  \n (1) deviceMaintenanceCardItemList_1[i].cardExt.deviceId = 路径参数regulatorDeviceId；  \n (2) deviceMaintenanceCardItemList_1[i].cardId = 路径参数maintenanceCardId；  \n deviceMaintenanceCardItemList_1的排序规则如下：  \n (1) 根据deviceMaintenanceCardItemList_1[i].maintenanceTime进行降序排序；  \n2. 返回信息 :  \n 根据deviceMaintenanceCardItemList_1对象集合及条件参数生成结果对象并返回;  \n",produces = "application/json")
    //endregion
    //region swagger参数 : getByRegulatorDeviceIdAndMaintenanceCardId
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "regulatorDeviceId", value = "调压设备编号",required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "maintenanceCardId", value = "维护卡编号",required = true, dataType = "int", paramType = "path"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where sourceRegulaTorTank_maintenanceCard_item.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where sourceRegulaTorTank_maintenanceCard_item.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : getByRegulatorDeviceIdAndMaintenanceCardId
    @RequestMapping(value = "/regulator-devices/{regulatorDeviceId}/maintenance-cards/{maintenanceCardId}/items", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<RegulatorDevice_MaintenanceCard_ItemGetModel> getByRegulatorDeviceIdAndMaintenanceCardId(@PathVariable("regulatorDeviceId") Integer regulatorDeviceId,
                                                                                                                   @PathVariable("maintenanceCardId") Integer maintenanceCardId,
                                                                                                                   @RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        RegulatorDevice_MaintenanceCard_ItemGetModel responseBody = regulatorDevice_maintenanceCard_itemService.getByRegulatorDeviceIdAndMaintenanceCardId(initHeader(), regulatorDeviceId, maintenanceCardId, query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}


































































































































































